package org.acra.b;

import android.content.Context;
import android.content.SharedPreferences;
import android.content.pm.PackageInfo;
import android.os.Build;
import android.os.Build.VERSION;
import android.os.Environment;
import android.text.format.Time;
import android.util.Log;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.PrintWriter;
import java.io.StringWriter;
import java.util.Arrays;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.UUID;
import org.acra.ACRA;
import org.acra.ReportField;
import org.acra.d.j;

public final class d
{
  private final Context a;
  private final SharedPreferences b;
  private final List c;
  private final Map d = new HashMap();
  private final Time e;
  private final String f;

  public d(Context paramContext, SharedPreferences paramSharedPreferences, Time paramTime, String paramString)
  {
    this.a = paramContext;
    this.b = paramSharedPreferences;
    this.e = paramTime;
    this.f = paramString;
    org.acra.c localc = ACRA.getConfig();
    ReportField[] arrayOfReportField = localc.d();
    if (arrayOfReportField.length != 0)
      Log.d(ACRA.LOG_TAG, "Using custom Report Fields");
    while (true)
    {
      this.c = Arrays.asList(arrayOfReportField);
      return;
      if ((localc.o() == null) || ("".equals(localc.o())))
      {
        Log.d(ACRA.LOG_TAG, "Using default Report Fields");
        arrayOfReportField = org.acra.e.c;
      }
      else
      {
        Log.d(ACRA.LOG_TAG, "Using default Mail Report Fields");
        arrayOfReportField = org.acra.e.b;
      }
    }
  }

  private String a()
  {
    StringBuilder localStringBuilder = new StringBuilder();
    Iterator localIterator = this.d.keySet().iterator();
    while (localIterator.hasNext())
    {
      String str1 = (String)localIterator.next();
      String str2 = (String)this.d.get(str1);
      localStringBuilder.append(str1);
      localStringBuilder.append(" = ");
      localStringBuilder.append(str2);
      localStringBuilder.append("\n");
    }
    return localStringBuilder.toString();
  }

  private String a(Throwable paramThrowable)
  {
    StringWriter localStringWriter = new StringWriter();
    PrintWriter localPrintWriter = new PrintWriter(localStringWriter);
    while (paramThrowable != null)
    {
      paramThrowable.printStackTrace(localPrintWriter);
      paramThrowable = paramThrowable.getCause();
    }
    String str = localStringWriter.toString();
    localPrintWriter.close();
    return str;
  }

  public String a(String paramString1, String paramString2)
  {
    return (String)this.d.put(paramString1, paramString2);
  }

  public c a(Throwable paramThrowable, boolean paramBoolean, Thread paramThread)
  {
    c localc = new c();
    while (true)
    {
      try
      {
        localc.put(ReportField.STACK_TRACE, a(paramThrowable));
        localc.put(ReportField.USER_APP_START_DATE, this.e.format3339(false));
        if (paramBoolean)
          localc.put(ReportField.IS_SILENT, "true");
        if (this.c.contains(ReportField.REPORT_ID))
          localc.put(ReportField.REPORT_ID, UUID.randomUUID().toString());
        if (this.c.contains(ReportField.INSTALLATION_ID))
          localc.put(ReportField.INSTALLATION_ID, org.acra.d.f.a(this.a));
        if (this.c.contains(ReportField.INITIAL_CONFIGURATION))
          localc.put(ReportField.INITIAL_CONFIGURATION, this.f);
        if (this.c.contains(ReportField.CRASH_CONFIGURATION))
          localc.put(ReportField.CRASH_CONFIGURATION, b.a(this.a));
        if ((!(paramThrowable instanceof OutOfMemoryError)) && (this.c.contains(ReportField.DUMPSYS_MEMINFO)))
          localc.put(ReportField.DUMPSYS_MEMINFO, h.a());
        if (this.c.contains(ReportField.PACKAGE_NAME))
          localc.put(ReportField.PACKAGE_NAME, this.a.getPackageName());
        if (this.c.contains(ReportField.BUILD))
          localc.put(ReportField.BUILD, o.b(Build.class) + o.a(Build.VERSION.class, "VERSION"));
        if (this.c.contains(ReportField.PHONE_MODEL))
          localc.put(ReportField.PHONE_MODEL, Build.MODEL);
        if (this.c.contains(ReportField.ANDROID_VERSION))
          localc.put(ReportField.ANDROID_VERSION, Build.VERSION.RELEASE);
        if (this.c.contains(ReportField.BRAND))
          localc.put(ReportField.BRAND, Build.BRAND);
        if (this.c.contains(ReportField.PRODUCT))
          localc.put(ReportField.PRODUCT, Build.PRODUCT);
        if (this.c.contains(ReportField.TOTAL_MEM_SIZE))
          localc.put(ReportField.TOTAL_MEM_SIZE, Long.toString(org.acra.d.k.b()));
        if (this.c.contains(ReportField.AVAILABLE_MEM_SIZE))
          localc.put(ReportField.AVAILABLE_MEM_SIZE, Long.toString(org.acra.d.k.a()));
        if (this.c.contains(ReportField.FILE_PATH))
          localc.put(ReportField.FILE_PATH, org.acra.d.k.b(this.a));
        if (this.c.contains(ReportField.DISPLAY))
          localc.put(ReportField.DISPLAY, f.a(this.a));
        if (this.c.contains(ReportField.USER_CRASH_DATE))
        {
          Time localTime = new Time();
          localTime.setToNow();
          localc.put(ReportField.USER_CRASH_DATE, localTime.format3339(false));
        }
        if (this.c.contains(ReportField.CUSTOM_DATA))
          localc.put(ReportField.CUSTOM_DATA, a());
        if (this.c.contains(ReportField.USER_EMAIL))
          localc.put(ReportField.USER_EMAIL, this.b.getString("acra.user.email", "N/A"));
        if (this.c.contains(ReportField.DEVICE_FEATURES))
          localc.put(ReportField.DEVICE_FEATURES, e.a(this.a));
        if (this.c.contains(ReportField.ENVIRONMENT))
          localc.put(ReportField.ENVIRONMENT, o.a(Environment.class));
        if (this.c.contains(ReportField.SETTINGS_SYSTEM))
          localc.put(ReportField.SETTINGS_SYSTEM, p.a(this.a));
        if (this.c.contains(ReportField.SETTINGS_SECURE))
          localc.put(ReportField.SETTINGS_SECURE, p.b(this.a));
        if (this.c.contains(ReportField.SETTINGS_GLOBAL))
          localc.put(ReportField.SETTINGS_GLOBAL, p.c(this.a));
        if (this.c.contains(ReportField.SHARED_PREFERENCES))
          localc.put(ReportField.SHARED_PREFERENCES, q.a(this.a));
        j localj = new j(this.a);
        PackageInfo localPackageInfo = localj.a();
        if (localPackageInfo != null)
        {
          if (this.c.contains(ReportField.APP_VERSION_CODE))
            localc.put(ReportField.APP_VERSION_CODE, Integer.toString(localPackageInfo.versionCode));
          if (this.c.contains(ReportField.APP_VERSION_NAME))
          {
            ReportField localReportField = ReportField.APP_VERSION_NAME;
            if (localPackageInfo.versionName == null)
              break label1420;
            str2 = localPackageInfo.versionName;
            localc.put(localReportField, str2);
          }
          if ((this.c.contains(ReportField.DEVICE_ID)) && (this.b.getBoolean("acra.deviceid.enable", true)) && (localj.a("android.permission.READ_PHONE_STATE")))
          {
            String str1 = org.acra.d.k.a(this.a);
            if (str1 != null)
              localc.put(ReportField.DEVICE_ID, str1);
          }
          if (((this.b.getBoolean("acra.syslog.enable", true)) && (localj.a("android.permission.READ_LOGS"))) || (a.a() >= 16))
          {
            Log.i(ACRA.LOG_TAG, "READ_LOGS granted! ACRA can include LogCat and DropBox data.");
            if (this.c.contains(ReportField.LOGCAT))
              localc.put(ReportField.LOGCAT, i.a(null));
            if (this.c.contains(ReportField.EVENTSLOG))
              localc.put(ReportField.EVENTSLOG, i.a("events"));
            if (this.c.contains(ReportField.RADIOLOG))
              localc.put(ReportField.RADIOLOG, i.a("radio"));
            if (this.c.contains(ReportField.DROPBOX))
              localc.put(ReportField.DROPBOX, g.a(this.a, ACRA.getConfig().a()));
            if (this.c.contains(ReportField.APPLICATION_LOG))
              localc.put(ReportField.APPLICATION_LOG, k.a(this.a, ACRA.getConfig().J(), ACRA.getConfig().K()));
            if (this.c.contains(ReportField.MEDIA_CODEC_LIST))
              localc.put(ReportField.MEDIA_CODEC_LIST, l.a());
            if (this.c.contains(ReportField.THREAD_DETAILS))
              localc.put(ReportField.THREAD_DETAILS, r.a(paramThread));
            if (!this.c.contains(ReportField.USER_IP))
              break label1417;
            localc.put(ReportField.USER_IP, org.acra.d.k.c());
            return localc;
          }
        }
        else
        {
          localc.put(ReportField.APP_VERSION_NAME, "Package info unavailable");
          continue;
        }
      }
      catch (RuntimeException localRuntimeException)
      {
        Log.e(ACRA.LOG_TAG, "Error while retrieving crash data", localRuntimeException);
        return localc;
        Log.i(ACRA.LOG_TAG, "READ_LOGS not allowed. ACRA will not include LogCat and DropBox data.");
        continue;
      }
      catch (FileNotFoundException localFileNotFoundException)
      {
        Log.e(ACRA.LOG_TAG, "Error : application log file " + ACRA.getConfig().J() + " not found.", localFileNotFoundException);
        return localc;
      }
      catch (IOException localIOException)
      {
        Log.e(ACRA.LOG_TAG, "Error while reading application log file " + ACRA.getConfig().J() + ".", localIOException);
      }
      label1417: return localc;
      label1420: String str2 = "not set";
    }
  }
}

/* Location:           D:\Studium\Bachelorarbeit\BA Marcus Wobig\BA\BA\Decompiler\PicturePassword APK\Programm\PicturePassword_dex2jar.jar
 * Qualified Name:     org.acra.b.d
 * JD-Core Version:    0.6.2
 */